/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package healthcare.coursework.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "PATIENT")
@NamedQueries({
    @NamedQuery(name = "Patient.findAll", query = "SELECT p FROM Patient p")})
public class Patient implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PATIENT_ID", nullable = false)
    private Long patientId;
    @Basic(optional = false)
    @Column(name = "FULL_NAME", nullable = false, length = 400)
    private String fullName;
    @Basic(optional = false)
    @Column(name = "DATE_OF_BIRTH", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfBirth;
    @Column(name = "JOB", length = 50)
    private String job;
    @Basic(optional = false)
    @Column(name = "ADDRESS", nullable = false, length = 500)
    private String address;
    @Column(name = "PHONE", length = 30)
    private String phone;
    @Column(name = "TRACKING_CODE", length = 10)
    private String trackCode;
    @Basic(optional = false)
    @Column(name = "IS_DELETED", nullable = false)
    private boolean isDeleted;
    @OneToMany( mappedBy = "patient", fetch = FetchType.EAGER)
    private List<MedicalHistory> medicalHistory;
    @OneToMany(mappedBy = "patient", fetch = FetchType.EAGER)
    private List<Diagnoses> diagnoses;
    @OneToMany( mappedBy = "patient", fetch = FetchType.EAGER)
    private List<TestSamples> testSamples;

    public Patient() {
    }

    public Patient(String fullName, Date dateOfBirth, String job, String address, String phone) {
        this.fullName = fullName;
        this.dateOfBirth = dateOfBirth;
        this.job = job;
        this.address = address;
        this.phone = phone;
    }


    public Patient(Long patientId) {
        this.patientId = patientId;
    }

    public Patient(Long patientId, String fullName, Date dateOfBirth, String address, boolean isDeleted) {
        this.patientId = patientId;
        this.fullName = fullName;
        this.dateOfBirth = dateOfBirth;
        this.address = address;
        this.isDeleted = isDeleted;
    }

    public Long getPatientId() {
        return patientId;
    }

    public void setPatientId(Long patientId) {
        this.patientId = patientId;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public Date getDateOfBirth() {
        return dateOfBirth;
    }

    public void setDateOfBirth(Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getTrackCode() {
        return trackCode;
    }

    public void setTrackCode(String trackCode) {
        this.trackCode = trackCode;
    }

  

    public boolean getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    public List<MedicalHistory> getMedicalHistory() {
        return medicalHistory;
    }

    public void setMedicalHistoryList(List<MedicalHistory> medicalHistory) {
        this.medicalHistory = medicalHistory;
    }

    public List<Diagnoses> getDiagnoses() {
        return diagnoses;
    }

    public void setDiagnoses(List<Diagnoses> diagnoses) {
        this.diagnoses = diagnoses;
    }

    public List<TestSamples> getTestSamplesList() {
        return testSamples;
    }

    public void setTestSamplesList(List<TestSamples> testSamples) {
        this.testSamples = testSamples;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (patientId != null ? patientId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Patient)) {
            return false;
        }
        Patient other = (Patient) object;
        if ((this.patientId == null && other.patientId != null) || (this.patientId != null && !this.patientId.equals(other.patientId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "healthcare.coursework.model.Patient[patientId=" + patientId + "]";
    }

}
